<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: Counter Functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__profile__functions__counter.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Counter Functions<div class="ingroups"><a class="el" href="group__group__energy__profiler.html">Profile      (Energy Profiler)</a> &raquo; <a class="el" href="group__group__profile__functions.html">Functions</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaa727295348b428f46dc3d0a7e1f1681f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__counter.html#gaa727295348b428f46dc3d0a7e1f1681f">Cy_Profile_ClearConfiguration</a> (void)</td></tr>
<tr class="memdesc:gaa727295348b428f46dc3d0a7e1f1681f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clears all counter configurations and sets all counters and overflow counters to 0.  <a href="#gaa727295348b428f46dc3d0a7e1f1681f">More...</a><br /></td></tr>
<tr class="separator:gaa727295348b428f46dc3d0a7e1f1681f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga254eeff2dec6c28e1819373ed6106c7c"><td class="memItemLeft" align="right" valign="top">__STATIC_INLINE void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__counter.html#ga254eeff2dec6c28e1819373ed6106c7c">Cy_Profile_ClearCounters</a> (void)</td></tr>
<tr class="memdesc:ga254eeff2dec6c28e1819373ed6106c7c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clears all hardware counters to 0.  <a href="#ga254eeff2dec6c28e1819373ed6106c7c">More...</a><br /></td></tr>
<tr class="separator:ga254eeff2dec6c28e1819373ed6106c7c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga077b14aae89e02d6e01699e873fe3a9b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter</a> (en_ep_mon_sel_t monitor, <a class="el" href="group__group__profile__enums.html#ga82efb19440328ed10ceb3ae66ac4e6f3">cy_en_profile_duration_t</a> duration, <a class="el" href="group__group__profile__enums.html#gaf4167388440a79a2671d7c1bea86785c">cy_en_profile_ref_clk_t</a> refClk, uint32_t weight)</td></tr>
<tr class="memdesc:ga077b14aae89e02d6e01699e873fe3a9b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configures and assigns a hardware profile counter to the list of used counters.  <a href="#ga077b14aae89e02d6e01699e873fe3a9b">More...</a><br /></td></tr>
<tr class="separator:ga077b14aae89e02d6e01699e873fe3a9b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga76efcb49377e1bbeffd2eab29d8673ca"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__counter.html#ga76efcb49377e1bbeffd2eab29d8673ca">Cy_Profile_FreeCounter</a> (<a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a> ctrAddr)</td></tr>
<tr class="memdesc:ga76efcb49377e1bbeffd2eab29d8673ca"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees up a counter from a previously-assigned monitor source.  <a href="#ga76efcb49377e1bbeffd2eab29d8673ca">More...</a><br /></td></tr>
<tr class="separator:ga76efcb49377e1bbeffd2eab29d8673ca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadb0af4c3dfab0094b3c37192f600f351"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__counter.html#gadb0af4c3dfab0094b3c37192f600f351">Cy_Profile_EnableCounter</a> (<a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a> ctrAddr)</td></tr>
<tr class="memdesc:gadb0af4c3dfab0094b3c37192f600f351"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enables an assigned counter.  <a href="#gadb0af4c3dfab0094b3c37192f600f351">More...</a><br /></td></tr>
<tr class="separator:gadb0af4c3dfab0094b3c37192f600f351"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7b44ab102e66cd5a0b243ac67dbd1c3c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__counter.html#ga7b44ab102e66cd5a0b243ac67dbd1c3c">Cy_Profile_DisableCounter</a> (<a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a> ctrAddr)</td></tr>
<tr class="memdesc:ga7b44ab102e66cd5a0b243ac67dbd1c3c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Disables an assigned counter.  <a href="#ga7b44ab102e66cd5a0b243ac67dbd1c3c">More...</a><br /></td></tr>
<tr class="separator:ga7b44ab102e66cd5a0b243ac67dbd1c3c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaa727295348b428f46dc3d0a7e1f1681f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa727295348b428f46dc3d0a7e1f1681f">&#9670;&nbsp;</a></span>Cy_Profile_ClearConfiguration()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Cy_Profile_ClearConfiguration </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Clears all counter configurations and sets all counters and overflow counters to 0. </p>
<p>Calls <a class="el" href="group__group__profile__functions__counter.html#ga254eeff2dec6c28e1819373ed6106c7c" title="Clears all hardware counters to 0. ">Cy_Profile_ClearCounters()</a> to clear counter registers.</p>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: A new profiling session with a different set of counter</span></div><div class="line"><span class="comment">                 configurations need to be allocated. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    uint8_t cntIdx;</div><div class="line">    </div><div class="line">    <span class="comment">/* Disable all the counters */</span></div><div class="line">    <span class="keywordflow">for</span>(cntIdx = 0u; cntIdx &lt; PROFILE_PRFL_CNT_NR; cntIdx++)</div><div class="line">    {</div><div class="line">        <span class="keywordflow">if</span>(<a class="code" href="group__group__profile__enums.html#gga7d980aa8f4c0159ccc47a973dd543e02a9328da8e423851a200dc18bceea5b54c">CY_PROFILE_SUCCESS</a> != <a class="code" href="group__group__profile__functions__counter.html#ga7b44ab102e66cd5a0b243ac67dbd1c3c">Cy_Profile_DisableCounter</a>(cntHandle[cntIdx]))</div><div class="line">        {</div><div class="line">            <span class="comment">/* Insert error handling */</span></div><div class="line">        }</div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">/* Clear all counter configurations */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__counter.html#gaa727295348b428f46dc3d0a7e1f1681f">Cy_Profile_ClearConfiguration</a>();</div><div class="line"></div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga254eeff2dec6c28e1819373ed6106c7c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga254eeff2dec6c28e1819373ed6106c7c">&#9670;&nbsp;</a></span>Cy_Profile_ClearCounters()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">__STATIC_INLINE void Cy_Profile_ClearCounters </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Clears all hardware counters to 0. </p>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: A new profiling window needs to be started with the counter</span></div><div class="line"><span class="comment">                 values reset to 0. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* Stop the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Clear all counters before starting a new profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__counter.html#ga254eeff2dec6c28e1819373ed6106c7c">Cy_Profile_ClearCounters</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* If applicable, clear the overflow bits in the data structure */</span></div><div class="line"></div><div class="line">    <span class="comment">/* Start the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a>();</div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga077b14aae89e02d6e01699e873fe3a9b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga077b14aae89e02d6e01699e873fe3a9b">&#9670;&nbsp;</a></span>Cy_Profile_ConfigureCounter()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a> Cy_Profile_ConfigureCounter </td>
          <td>(</td>
          <td class="paramtype">en_ep_mon_sel_t&#160;</td>
          <td class="paramname"><em>monitor</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__profile__enums.html#ga82efb19440328ed10ceb3ae66ac4e6f3">cy_en_profile_duration_t</a>&#160;</td>
          <td class="paramname"><em>duration</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__profile__enums.html#gaf4167388440a79a2671d7c1bea86785c">cy_en_profile_ref_clk_t</a>&#160;</td>
          <td class="paramname"><em>refClk</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>weight</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Configures and assigns a hardware profile counter to the list of used counters. </p>
<p>This function assigns an available profile counter to a slot in the internal software data structure and returns the handle for that slot location. The data structure is used to keep track of the counter status and to implement a 64-bit profile counter. If no counter slots are available, the function returns a NULL pointer.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">monitor</td><td>The monitor source number</td></tr>
    <tr><td class="paramname">duration</td><td>Events are monitored (0), or duration is monitored (1)</td></tr>
    <tr><td class="paramname">refClk</td><td>Counter reference clock</td></tr>
    <tr><td class="paramname">weight</td><td>Weighting factor for the counter value</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A pointer to the counter data structure. NULL if no counter is available.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: SCB0 bus transfers need to be monitored during a fixed window.</span></div><div class="line"><span class="comment">                 The profile interrupt is configured using the sysint driver. </span></div><div class="line"><span class="comment">                 It&#39;s handler function is Cy_Profile_ISR(). */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Initialize the energy profiler */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga3a4f9cb2191f4c950821aca1c56766b2">Cy_Profile_Init</a>();</div><div class="line">    <a class="code" href="group__group__profile__functions__counter.html#gaa727295348b428f46dc3d0a7e1f1681f">Cy_Profile_ClearConfiguration</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Configure a profile counter to monitor the SCB0 bus transfer events */</span></div><div class="line">    cntHandle[0] = <a class="code" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter</a>(SCB0_MONITOR_AHB,        <span class="comment">/* SCB0 bus transfer count */</span></div><div class="line">                                                <a class="code" href="group__group__profile__enums.html#gga82efb19440328ed10ceb3ae66ac4e6f3a4164d3e39093109cb37d74adac47c6c3">CY_PROFILE_EVENT</a>,       <span class="comment">/* Count number of SCB0 bus transfers */</span> </div><div class="line">                                                <a class="code" href="group__group__profile__enums.html#ggaf4167388440a79a2671d7c1bea86785cab734f4cdfa75f56ad1bbecdfd22dc137">CY_PROFILE_CLK_TIMER</a>,   <span class="comment">/* Ignored for &quot;event&quot; counting */</span></div><div class="line">                                                20000UL);               <span class="comment">/* Weight of 20000 (example) */</span></div><div class="line">    <span class="keywordflow">if</span>(cntHandle[0] == NULL)</div><div class="line">    {</div><div class="line">        <span class="comment">/* Cannot allocate this counter. Check and try again. */</span></div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">/* Enable the assigned counter */</span></div><div class="line">    (void)<a class="code" href="group__group__profile__functions__counter.html#gadb0af4c3dfab0094b3c37192f600f351">Cy_Profile_EnableCounter</a>(cntHandle[0]);</div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga76efcb49377e1bbeffd2eab29d8673ca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga76efcb49377e1bbeffd2eab29d8673ca">&#9670;&nbsp;</a></span>Cy_Profile_FreeCounter()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a> Cy_Profile_FreeCounter </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a>&#160;</td>
          <td class="paramname"><em>ctrAddr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Frees up a counter from a previously-assigned monitor source. </p>
<p><a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a> must have been called for this counter before calling this function.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ctrAddr</td><td>The handle to the assigned counter (returned by calling <a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a>).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>The counter is not disabled by this function.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: A profile counter in position #0 was previously in use. It needs</span></div><div class="line"><span class="comment">                 to be reconfigured to monitor the CM0+ active cycles count. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Free the profile counter in position #0 */</span></div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="group__group__profile__enums.html#gga7d980aa8f4c0159ccc47a973dd543e02a9328da8e423851a200dc18bceea5b54c">CY_PROFILE_SUCCESS</a> != <a class="code" href="group__group__profile__functions__counter.html#ga76efcb49377e1bbeffd2eab29d8673ca">Cy_Profile_FreeCounter</a>(cntHandle[0]))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">/* Configure a profile counter to monitor the CM0+ active cycle count events */</span></div><div class="line">    cntHandle[0] = <a class="code" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter</a>(CPUSS_MONITOR_CM0,       <span class="comment">/* CM0+ active cycle count */</span></div><div class="line">                                                <a class="code" href="group__group__profile__enums.html#gga82efb19440328ed10ceb3ae66ac4e6f3a4164d3e39093109cb37d74adac47c6c3">CY_PROFILE_EVENT</a>,       <span class="comment">/* Count number of CM0+ active cycles */</span> </div><div class="line">                                                <a class="code" href="group__group__profile__enums.html#ggaf4167388440a79a2671d7c1bea86785cab734f4cdfa75f56ad1bbecdfd22dc137">CY_PROFILE_CLK_TIMER</a>,   <span class="comment">/* Ignored for &quot;event&quot; counting */</span></div><div class="line">                                                40000UL);               <span class="comment">/* Weight of 40000 (example) */</span></div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="gadb0af4c3dfab0094b3c37192f600f351"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadb0af4c3dfab0094b3c37192f600f351">&#9670;&nbsp;</a></span>Cy_Profile_EnableCounter()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a> Cy_Profile_EnableCounter </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a>&#160;</td>
          <td class="paramname"><em>ctrAddr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enables an assigned counter. </p>
<p><a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a> must have been called for this counter before calling this function.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ctrAddr</td><td>The handle to the assigned counter, (returned by calling <a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a>).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: A profile counter needs to be configured and enabled to count</span></div><div class="line"><span class="comment">                 the number of HFCLK0 cycles in the profiling window. The energy </span></div><div class="line"><span class="comment">                 profiler is initialized and the profile interrupt is configured</span></div><div class="line"><span class="comment">                 and enabled. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Configure a profile counter to count the number of HFCLK0 cycles in the profiling window */</span></div><div class="line">    cntHandle[0] = <a class="code" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter</a>(PROFILE_ONE,         <span class="comment">/* Constant 1 (always count) */</span></div><div class="line">                                                <a class="code" href="group__group__profile__enums.html#gga82efb19440328ed10ceb3ae66ac4e6f3a175867d1f00ea74e17f4290d7bdf468d">CY_PROFILE_DURATION</a>,<span class="comment">/* Count number of clock cycles */</span> </div><div class="line">                                                <a class="code" href="group__group__profile__enums.html#ggaf4167388440a79a2671d7c1bea86785ca1e37f3a78d1d64e950d826d26793cb98">CY_PROFILE_CLK_HF</a>,  <span class="comment">/* HFCLK0 */</span></div><div class="line">                                                1UL);               <span class="comment">/* Normalization weight of 1 */</span></div><div class="line">    </div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="group__group__profile__enums.html#gga7d980aa8f4c0159ccc47a973dd543e02a9328da8e423851a200dc18bceea5b54c">CY_PROFILE_SUCCESS</a> != <a class="code" href="group__group__profile__functions__counter.html#gadb0af4c3dfab0094b3c37192f600f351">Cy_Profile_EnableCounter</a>(cntHandle[0]))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">/* Start the profiling window when ready. */</span></div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga7b44ab102e66cd5a0b243ac67dbd1c3c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7b44ab102e66cd5a0b243ac67dbd1c3c">&#9670;&nbsp;</a></span>Cy_Profile_DisableCounter()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a> Cy_Profile_DisableCounter </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a>&#160;</td>
          <td class="paramname"><em>ctrAddr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Disables an assigned counter. </p>
<p><a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a> must have been called for this counter before calling this function.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ctrAddr</td><td>The handle to the assigned counter, (returned by calling <a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a>).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: A profile counter assigned to position #0 is no longer needed </span></div><div class="line"><span class="comment">       and can be disabled. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Disable the profile counter in position #0 */</span></div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="group__group__profile__enums.html#gga7d980aa8f4c0159ccc47a973dd543e02a9328da8e423851a200dc18bceea5b54c">CY_PROFILE_SUCCESS</a> != <a class="code" href="group__group__profile__functions__counter.html#ga7b44ab102e66cd5a0b243ac67dbd1c3c">Cy_Profile_DisableCounter</a>(cntHandle[0]))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">    </div><div class="line">    <span class="comment">/* Free the profile counter in position #0 */</span></div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="group__group__profile__enums.html#gga7d980aa8f4c0159ccc47a973dd543e02a9328da8e423851a200dc18bceea5b54c">CY_PROFILE_SUCCESS</a> != <a class="code" href="group__group__profile__functions__counter.html#ga76efcb49377e1bbeffd2eab29d8673ca">Cy_Profile_FreeCounter</a>(cntHandle[0]))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
